package me.ymfs.springboot.guice.exception;

import lombok.extern.slf4j.Slf4j;
import me.ymfs.springboot.guice.vo.RespVO;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(BaseException.class)
    public RespVO handleBaseException(BaseException e) {
        log.error(e.getMessage(), e);
        return RespVO.builder().code(e.getErrorCode().getCode())
                .msg(e.getErrorCode().getMsg()).build();
    }

}
